<%@ page import="com.model.User" %>
<%@ page import="com.dao.ShoppingcartDao" %>
<%@ page import="java.util.List" %>
<%@ page import="com.model.Shoppingcart" %>
<%@ page import="com.dao.GoodsDao" %>
<%@ page import="com.model.Goods" %><%--
  Created by IntelliJ IDEA.
  User: jk
  Date: 2017/11/28
  Time: 21:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">

<%
    Boolean isOnline;
    User user = (User) session.getAttribute("user");
    ShoppingcartDao shoppingcartDao = new ShoppingcartDao();
    GoodsDao goodsDao = new GoodsDao();
    String user_name = null;
    String user_id = null;
    List<Shoppingcart> shoppingcarts = null;
    if(user == null){
        isOnline=false;
    }
    else {
        isOnline = true;
        user_name = user.getUserName();
        user_id = user.getId();
        shoppingcarts = shoppingcartDao.getShoppingcartByUserId(user_id);
    }
%>
<head>
    <meta charset="UTF-8">
    <title>我的购物车</title>
    <link rel="stylesheet" href="/store/css/shopCart.css" type="text/css">
    <link href="/store/css/head.css" rel="stylesheet" type="text/css">
    <script language="JavaScript">
        var isOnline= <%= isOnline%> ;
        var username="<%= user_name%>";
    </script>
    <script language="JavaScript" src="/store/js/jquery-3.2.1.min.js"></script>
    <script language="JavaScript" src="/store/js/head.js"></script>
    <script language="JavaScript" src="/store/js/shopCart.js"></script>


</head>
<body>

<header>
    <jsp:include page="head.jsp"></jsp:include>
</header>

<div class="main">

    <ul class="goods_type">
        <li style="border-color: red">全部商品</li>
    </ul>

    <div class="main_content">
        <div class="goods_th">

            <div class="goods_msg">
                商品信息
            </div>
            <div class="operate">
                操作
            </div>
            <div class="total_price">
                金额
            </div>
            <div class="goods_num">
                数量
            </div>
            <div class="uit_price">
                单价
            </div>
        </div>



        <%
            for (Shoppingcart shoppingcart: shoppingcarts){
                Goods goods = goodsDao.getGoodsByGoodsId(shoppingcart.getGoods_id());
        %>
        <div class="single_goods">
            <div class="check_goods">
                <input type="checkbox" class="select">
            </div>

            <div class="good_img">
                <img alt="零食图片" src="<%= goods.getPhoto_address() %>">
            </div>

            <div class="goods_name">
                <%= goods.getGoods_name() %>
            </div>

            <div class="operate">
                <form name="" action="/store/shoppingcart.do" method="GET">
                    <input type="submit" value="删除" name="delete">
                    <input type="text" value="delete" name="action" STYLE="visibility: hidden; width: 0;height: 0">
                    <input type="text" value="<%= shoppingcart.getShoppingcart_id()%>" class="goods_id_input" name="shoppingcartId" STYLE="visibility: hidden; width: 0;height: 0">
                </form>
            </div>
            <div class="total_price">
                ￥<span class="goods_all_price">
                    <%= Integer.parseInt(goods.getGoods_price())* Integer.parseInt(shoppingcart.getNumber())%>
                </span>
            </div>
            <div class="goods_num">
                <div>
                    <p class="down">-</p>
                    <input type="text" value="<%=shoppingcart.getNumber() %>" class="goodsNum">
                    <p class="up">+</p>
                </div>

            </div>
            <div class="uit_price">
                ￥<span class="uitPrice"><%= goods.getGoods_price() %></span>
            </div>
        </div>
        <%}%>





        <div class="clear">

                <div class="general_election">
                    <span><input type="checkbox"><span>全选</span></span>
                </div>


            <div class="delete">
                <form name="" action="/store/shoppingcart.do" id="delete_submit" method="get">
                    <input type="text" style="display: none" value="" name="shoppingcartId" class="delete_input">
                    <input type="submit" value="删除" class="delete_submit">
                    <input type="text" value="delete" name="action" STYLE="visibility: hidden">
                </form>
            </div>
            <div class="clear_button">
                <form name="clear" action="" method="get">
                    <input type="submit" value="结算">
                </form>
            </div>
            <div class="all_price">
                <span>合计（不含运费）：</span><span class="price">0.00</span>
            </div>
            <div class="selected_num">
                <span>已选商品</span><span class="num">0</span><span>件</span>
            </div>
        </div>

    </div>
</div>
</body>
</html>
